﻿#region Using

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace XNgine.Util
{
    public static class GraphicsUtil
    {
        /// <summary>
        /// This helper draws a translucent black fullscreen sprite, used for fading
        /// in and out, and for darkening the background behind popups.
        /// </summary>
        public static void FadeBackBufferToBlack(byte alpha)
        {
            Viewport viewport = XEngine.Instance.GraphicsDevice.Viewport;

            SpriteBatch sb = XEngine.Instance.SpriteBatch;

            sb.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred,
                     SaveStateMode.SaveState);

            sb.Draw(XEngine.Instance.Content.Load<Texture2D>("Textures/blank"),
                    new Rectangle(0, 0, viewport.Width, viewport.Height),
                    new Color(0, 0, 0, alpha));
            sb.End();
        }
    }
}